{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Map Medical Subject Headings (MeSH) to UMLS and save to database\n",
    "\n",
    "This example demonstrates the typical workflow to populate a MESH2UMLS database table relating all concets associated with all MESH terms in the input database. \n",
    "\n",
    "**Note:** This example uses the database created by examples/pubmed_search_and_save script/notebook\n",
    "\n",
    "The following backends are supported for storing the results:\n",
    "\n",
    "* [MySQL](#MySQL)\n",
    "* [SQLite](#SQLite)\n",
    "\n",
    "Authors: Isabel Restrepo <br>\n",
    "BCBI - Brown University <br>\n",
    "Version: Julia 0.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: Method definition ==(Base.Nullable{S}, Base.Nullable{T}) in module Base at nullable.jl:238 overwritten in module NullableArrays at /Users/isa/.julia/v0.6/NullableArrays/src/operators.jl:99.\n"
     ]
    }
   ],
   "source": [
    "using SQLite\n",
    "using MySQL\n",
    "using BioMedQuery.Processes\n",
    "using BioServices.UMLS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# credentials are environment variables (e.g set in your .juliarc)\n",
    "umls_user = ENV[\"UMLS_USER\"];\n",
    "umls_pswd = ENV[\"UMLS_PSSWD\"];\n",
    "results_dir = \"./results\";"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='MySQL'></a>\n",
    "#### Using MySQL as a backend"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "----------Matching MESH to UMLS-----------\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mUTS: Reading TGT from file\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 18 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 45 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 48 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 31 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 20 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 11 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 8 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 30 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 15 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 34 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 9 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 24 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 46 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 2 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 14 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 32 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 13 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 6 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 19 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 26 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 3 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 12 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 21 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 25 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 22 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 28 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 17 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 10 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 41 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 33 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 50 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 5 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 7 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 1 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 4 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 36 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 47 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 27 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 44 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 38 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 49 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 39 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 42 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 37 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 16 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 23 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 40 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 29 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 51 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 35 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 43 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 52 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 51 out of 52\n",
      "\u001b[39m"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  8.679146 seconds (3.28 M allocations: 219.505 MiB, 1.12% gc time)\n"
     ]
    }
   ],
   "source": [
    "host=\"127.0.0.1\" \n",
    "mysql_usr=\"root\"\n",
    "mysql_pswd=\"\"\n",
    "dbname=\"pubmed_obesity_2010_2012\"\n",
    "\n",
    "db_mysql = mysql_connect(host, mysql_usr, mysql_pswd, dbname)\n",
    "@time map_mesh_to_umls_async!(db_mysql, umls_user, umls_pswd; append_results=false)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Explore output table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>mesh</th><th>umls</th></tr></thead><tbody><tr><th>1</th><td>Adult</td><td>Age Group</td></tr><tr><th>2</th><td>Age Distribution</td><td>Quantitative Concept</td></tr><tr><th>3</th><td>Aged</td><td>Organism Attribute</td></tr><tr><th>4</th><td>Aged, 80 and over</td><td>Age Group</td></tr><tr><th>5</th><td>Analysis of Variance</td><td>Quantitative Concept</td></tr><tr><th>6</th><td>Biomarkers</td><td>Clinical Attribute</td></tr><tr><th>7</th><td>Body Mass Index</td><td>Diagnostic Procedure</td></tr><tr><th>8</th><td>Body Weight</td><td>Organism Attribute</td></tr><tr><th>9</th><td>C-Reactive Protein</td><td>Amino Acid, Peptide, or Protein</td></tr><tr><th>10</th><td>C-Reactive Protein</td><td>Immunologic Factor</td></tr><tr><th>11</th><td>Case-Control Studies</td><td>Research Activity</td></tr><tr><th>12</th><td>Child</td><td>Age Group</td></tr><tr><th>13</th><td>Cross-Sectional Studies</td><td>Research Activity</td></tr><tr><th>14</th><td>Exercise</td><td>Daily or Recreational Activity</td></tr><tr><th>15</th><td>Fatigue</td><td>Sign or Symptom</td></tr><tr><th>16</th><td>Female</td><td>Population Group</td></tr><tr><th>17</th><td>Fibromyalgia</td><td>Disease or Syndrome</td></tr><tr><th>18</th><td>Germany</td><td>Geographic Area</td></tr><tr><th>19</th><td>Health Status</td><td>Qualitative Concept</td></tr><tr><th>20</th><td>Humans</td><td>Human</td></tr><tr><th>21</th><td>Incidence</td><td>Quantitative Concept</td></tr><tr><th>22</th><td>Japan</td><td>Geographic Area</td></tr><tr><th>23</th><td>Logistic Models</td><td>Intellectual Product</td></tr><tr><th>24</th><td>Logistic Models</td><td>Quantitative Concept</td></tr><tr><th>25</th><td>Male</td><td>Organism Attribute</td></tr><tr><th>26</th><td>Metabolic Syndrome</td><td>Disease or Syndrome</td></tr><tr><th>27</th><td>Middle Aged</td><td>Age Group</td></tr><tr><th>28</th><td>Nutrition Surveys</td><td>Research Activity</td></tr><tr><th>29</th><td>Obesity</td><td>Disease or Syndrome</td></tr><tr><th>30</th><td>Obesity, Abdominal</td><td>Finding</td></tr><tr><th>&vellip;</th><td>&vellip;</td><td>&vellip;</td></tr></tbody></table>"
      ],
      "text/plain": [
       "56×2 DataFrames.DataFrame\n",
       "│ Row │ mesh                         │ umls                              │\n",
       "├─────┼──────────────────────────────┼───────────────────────────────────┤\n",
       "│ 1   │ \"Adult\"                      │ \"Age Group\"                       │\n",
       "│ 2   │ \"Age Distribution\"           │ \"Quantitative Concept\"            │\n",
       "│ 3   │ \"Aged\"                       │ \"Organism Attribute\"              │\n",
       "│ 4   │ \"Aged, 80 and over\"          │ \"Age Group\"                       │\n",
       "│ 5   │ \"Analysis of Variance\"       │ \"Quantitative Concept\"            │\n",
       "│ 6   │ \"Biomarkers\"                 │ \"Clinical Attribute\"              │\n",
       "│ 7   │ \"Body Mass Index\"            │ \"Diagnostic Procedure\"            │\n",
       "│ 8   │ \"Body Weight\"                │ \"Organism Attribute\"              │\n",
       "│ 9   │ \"C-Reactive Protein\"         │ \"Amino Acid, Peptide, or Protein\" │\n",
       "│ 10  │ \"C-Reactive Protein\"         │ \"Immunologic Factor\"              │\n",
       "│ 11  │ \"Case-Control Studies\"       │ \"Research Activity\"               │\n",
       "⋮\n",
       "│ 45  │ \"Severity of Illness Index\"  │ \"Quantitative Concept\"            │\n",
       "│ 46  │ \"Sex Distribution\"           │ \"Quantitative Concept\"            │\n",
       "│ 47  │ \"Sleep Apnea, Obstructive\"   │ \"Disease or Syndrome\"             │\n",
       "│ 48  │ \"Sports\"                     │ \"Daily or Recreational Activity\"  │\n",
       "│ 49  │ \"Surveys and Questionnaires\" │ \"Research Activity\"               │\n",
       "│ 50  │ \"Television\"                 │ \"Manufactured Object\"             │\n",
       "│ 51  │ \"Thyrotropin\"                │ \"Amino Acid, Peptide, or Protein\" │\n",
       "│ 52  │ \"Thyrotropin\"                │ \"Hormone\"                         │\n",
       "│ 53  │ \"Thyrotropin\"                │ \"Pharmacologic Substance\"         │\n",
       "│ 54  │ \"Waist Circumference\"        │ \"Clinical Attribute\"              │\n",
       "│ 55  │ \"Weight Gain\"                │ \"Finding\"                         │\n",
       "│ 56  │ \"Young Adult\"                │ \"Age Group\"                       │"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "BioMedQuery.DBUtils.db_query(db_mysql, \"SELECT * FROM mesh2umls;\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "<a id='SQLite'></a>\n",
    "#### Using SQLite as a backend"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "----------Matching MESH to UMLS-----------\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mUTS: Reading TGT from file\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 1 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 2 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 4 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 45 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 3 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 19 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 6 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 47 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 25 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 20 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 27 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 16 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 26 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 22 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 48 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 15 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 50 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 49 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 14 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 9 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 11 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 44 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 13 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 18 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 51 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 32 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 10 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 43 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 40 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 29 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 41 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 28 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 34 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 46 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 7 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 35 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 36 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 38 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 31 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 24 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 12 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 21 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 42 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 23 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 30 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 37 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 39 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 8 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 17 out of 52\n",
      "\u001b[39m\u001b[36mDescriptor 33 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 5 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 51 out of 52\n",
      "\u001b[39m\u001b[1m\u001b[36mINFO: \u001b[39m\u001b[22m\u001b[36mDescriptor 52 out of 52\n",
      "\u001b[39m"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  6.235168 seconds (1.09 M allocations: 101.123 MiB, 1.82% gc time)\n"
     ]
    }
   ],
   "source": [
    "db_path=\"$(results_dir)/pubmed_obesity_2010_2012.db\"\n",
    "db_sqlite = SQLite.DB(db_path)\n",
    "@time map_mesh_to_umls_async!(db_sqlite, umls_user, umls_pswd; append_results=false)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>mesh</th><th>umls</th></tr></thead><tbody><tr><th>1</th><td>Nullable{String}(\"Adult\")</td><td>Nullable{String}(\"Age Group\")</td></tr><tr><th>2</th><td>Nullable{String}(\"Analysis of Variance\")</td><td>Nullable{String}(\"Quantitative Concept\")</td></tr><tr><th>3</th><td>Nullable{String}(\"Metabolic Syndrome\")</td><td>Nullable{String}(\"Disease or Syndrome\")</td></tr><tr><th>4</th><td>Nullable{String}(\"Health Status\")</td><td>Nullable{String}(\"Qualitative Concept\")</td></tr><tr><th>5</th><td>Nullable{String}(\"Surveys and Questionnaires\")</td><td>Nullable{String}(\"Research Activity\")</td></tr><tr><th>6</th><td>Nullable{String}(\"Obesity\")</td><td>Nullable{String}(\"Disease or Syndrome\")</td></tr><tr><th>7</th><td>Nullable{String}(\"Aged\")</td><td>Nullable{String}(\"Organism Attribute\")</td></tr><tr><th>8</th><td>Nullable{String}(\"Young Adult\")</td><td>Nullable{String}(\"Age Group\")</td></tr><tr><th>9</th><td>Nullable{String}(\"Physical Fitness\")</td><td>Nullable{String}(\"Idea or Concept\")</td></tr><tr><th>10</th><td>Nullable{String}(\"Reference Values\")</td><td>Nullable{String}(\"Quantitative Concept\")</td></tr><tr><th>11</th><td>Nullable{String}(\"Aged, 80 and over\")</td><td>Nullable{String}(\"Age Group\")</td></tr><tr><th>12</th><td>Nullable{String}(\"Pain\")</td><td>Nullable{String}(\"Food\")</td></tr><tr><th>13</th><td>Nullable{String}(\"C-Reactive Protein\")</td><td>Nullable{String}(\"Immunologic Factor\")</td></tr><tr><th>14</th><td>Nullable{String}(\"C-Reactive Protein\")</td><td>Nullable{String}(\"Amino Acid, Peptide, or Protein\")</td></tr><tr><th>15</th><td>Nullable{String}(\"Obesity, Abdominal\")</td><td>Nullable{String}(\"Finding\")</td></tr><tr><th>16</th><td>Nullable{String}(\"Waist Circumference\")</td><td>Nullable{String}(\"Clinical Attribute\")</td></tr><tr><th>17</th><td>Nullable{String}(\"Thyrotropin\")</td><td>Nullable{String}(\"Amino Acid, Peptide, or Protein\")</td></tr><tr><th>18</th><td>Nullable{String}(\"Thyrotropin\")</td><td>Nullable{String}(\"Hormone\")</td></tr><tr><th>19</th><td>Nullable{String}(\"Thyrotropin\")</td><td>Nullable{String}(\"Pharmacologic Substance\")</td></tr><tr><th>20</th><td>Nullable{String}(\"Female\")</td><td>Nullable{String}(\"Population Group\")</td></tr><tr><th>21</th><td>Nullable{String}(\"Fatigue\")</td><td>Nullable{String}(\"Sign or Symptom\")</td></tr><tr><th>22</th><td>Nullable{String}(\"Male\")</td><td>Nullable{String}(\"Organism Attribute\")</td></tr><tr><th>23</th><td>Nullable{String}(\"Republic of Korea\")</td><td>Nullable{String}(\"Geographic Area\")</td></tr><tr><th>24</th><td>Nullable{String}(\"Risk Factors\")</td><td>Nullable{String}(\"Finding\")</td></tr><tr><th>25</th><td>Nullable{String}(\"Sex Distribution\")</td><td>Nullable{String}(\"Quantitative Concept\")</td></tr><tr><th>26</th><td>Nullable{String}(\"Sedentary Lifestyle\")</td><td>Nullable{String}(\"Finding\")</td></tr><tr><th>27</th><td>Nullable{String}(\"Germany\")</td><td>Nullable{String}(\"Geographic Area\")</td></tr><tr><th>28</th><td>Nullable{String}(\"Humans\")</td><td>Nullable{String}(\"Human\")</td></tr><tr><th>29</th><td>Nullable{String}(\"Biomarkers\")</td><td>Nullable{String}(\"Clinical Attribute\")</td></tr><tr><th>30</th><td>Nullable{String}(\"Japan\")</td><td>Nullable{String}(\"Geographic Area\")</td></tr><tr><th>&vellip;</th><td>&vellip;</td><td>&vellip;</td></tr></tbody></table>"
      ],
      "text/plain": [
       "56×2 DataFrames.DataFrame\n",
       "│ Row │ mesh                         │ umls                             │\n",
       "├─────┼──────────────────────────────┼──────────────────────────────────┤\n",
       "│ 1   │ \"Adult\"                      │ \"Age Group\"                      │\n",
       "│ 2   │ \"Analysis of Variance\"       │ \"Quantitative Concept\"           │\n",
       "│ 3   │ \"Metabolic Syndrome\"         │ \"Disease or Syndrome\"            │\n",
       "│ 4   │ \"Health Status\"              │ \"Qualitative Concept\"            │\n",
       "│ 5   │ \"Surveys and Questionnaires\" │ \"Research Activity\"              │\n",
       "│ 6   │ \"Obesity\"                    │ \"Disease or Syndrome\"            │\n",
       "│ 7   │ \"Aged\"                       │ \"Organism Attribute\"             │\n",
       "│ 8   │ \"Young Adult\"                │ \"Age Group\"                      │\n",
       "│ 9   │ \"Physical Fitness\"           │ \"Idea or Concept\"                │\n",
       "│ 10  │ \"Reference Values\"           │ \"Quantitative Concept\"           │\n",
       "│ 11  │ \"Aged, 80 and over\"          │ \"Age Group\"                      │\n",
       "⋮\n",
       "│ 45  │ \"Body Mass Index\"            │ \"Diagnostic Procedure\"           │\n",
       "│ 46  │ \"Nutrition Surveys\"          │ \"Research Activity\"              │\n",
       "│ 47  │ \"Middle Aged\"                │ \"Age Group\"                      │\n",
       "│ 48  │ \"Fibromyalgia\"               │ \"Disease or Syndrome\"            │\n",
       "│ 49  │ \"Pain Measurement\"           │ \"Diagnostic Procedure\"           │\n",
       "│ 50  │ \"ROC Curve\"                  │ \"Quantitative Concept\"           │\n",
       "│ 51  │ \"Television\"                 │ \"Manufactured Object\"            │\n",
       "│ 52  │ \"Severity of Illness Index\"  │ \"Quantitative Concept\"           │\n",
       "│ 53  │ \"Weight Gain\"                │ \"Finding\"                        │\n",
       "│ 54  │ \"Sports\"                     │ \"Daily or Recreational Activity\" │\n",
       "│ 55  │ \"Exercise\"                   │ \"Daily or Recreational Activity\" │\n",
       "│ 56  │ \"Pediatric Obesity\"          │ \"Disease or Syndrome\"            │"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "BioMedQuery.DBUtils.db_query(db_sqlite, \"SELECT * FROM mesh2umls;\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Julia 0.6.0",
   "language": "julia",
   "name": "julia-0.6"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "0.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
